﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using DAL;
using System.Web.Compilation;
using System.Web.UI;

/// <summary>
/// Summary description for CSViewRouterHandler
/// </summary>
public class CSViewRouterHandler : IRouteHandler
{
    public CSViewRouterHandler()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        try
        {
            string strdata = requestContext.RouteData.Values["data"] as string;
            string[] arrdata = strdata.Split('_');
            switch (arrdata[0])
            {
                case "cre":
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("~/CSManager/LapPhieu.aspx", typeof(Page)) as Page;

                    }
                case "sv":
                    {
                        string ngay = arrdata[1];
                        string buoi = arrdata[2];
                        string dsid = arrdata[3];
                        HttpContext.Current.Items["ngay"] = ngay;
                        HttpContext.Current.Items["buoi"] = buoi;
                        HttpContext.Current.Items["dsid"] = dsid;
                        return BuildManager.CreateInstanceFromVirtualPath("~/CSManager/LapPhieu_ChiTiet.aspx", typeof(Page)) as Page;

                    }
                case "his":
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("~/CSManager/LapPhieu_Xem_LichSu.aspx", typeof(Page)) as Page;

                    }
                case "hisdetail":
                    {
                        string ngay = arrdata[1];
                        string buoi = arrdata[2];
                        string id = arrdata[3];
                        HttpContext.Current.Items["ngay"] = ngay;
                        HttpContext.Current.Items["buoi"] = buoi;
                        HttpContext.Current.Items["id"] = id;
                        return BuildManager.CreateInstanceFromVirtualPath("~/CSManager/LapPhieu_Xem_LichSu_ChiTiet.aspx", typeof(Page)) as Page;
                    }               

                default:
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("~/CSManager/LapPhieu.aspx", typeof(Page)) as Page;

                    }
            }
        }
        catch
        {
            return null;
        }


    }
}